/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.eclipsecon.dui.swtmodel.impl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipsecon.dui.swtmodel.MGridLayout;
import org.eclipsecon.dui.swtmodel.SwtmodelPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>MGrid Layout</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.eclipsecon.dui.swtmodel.impl.MGridLayoutImpl#getNumColumns <em>Num Columns</em>}</li>
 *   <li>{@link org.eclipsecon.dui.swtmodel.impl.MGridLayoutImpl#isMakeColumnsEqualWidth <em>Make Columns Equal Width</em>}</li>
 *   <li>{@link org.eclipsecon.dui.swtmodel.impl.MGridLayoutImpl#getMarginWidth <em>Margin Width</em>}</li>
 *   <li>{@link org.eclipsecon.dui.swtmodel.impl.MGridLayoutImpl#getMarginHeight <em>Margin Height</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MGridLayoutImpl extends MLayoutImpl implements MGridLayout {
	/**
	 * The default value of the '{@link #getNumColumns() <em>Num Columns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumColumns()
	 * @generated
	 * @ordered
	 */
	protected static final int NUM_COLUMNS_EDEFAULT = 1;

	/**
	 * The cached value of the '{@link #getNumColumns() <em>Num Columns</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumColumns()
	 * @generated
	 * @ordered
	 */
	protected int numColumns = NUM_COLUMNS_EDEFAULT;

	/**
	 * The default value of the '{@link #isMakeColumnsEqualWidth() <em>Make Columns Equal Width</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isMakeColumnsEqualWidth()
	 * @generated
	 * @ordered
	 */
	protected static final boolean MAKE_COLUMNS_EQUAL_WIDTH_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isMakeColumnsEqualWidth() <em>Make Columns Equal Width</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isMakeColumnsEqualWidth()
	 * @generated
	 * @ordered
	 */
	protected boolean makeColumnsEqualWidth = MAKE_COLUMNS_EQUAL_WIDTH_EDEFAULT;

	/**
	 * The default value of the '{@link #getMarginWidth() <em>Margin Width</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMarginWidth()
	 * @generated
	 * @ordered
	 */
	protected static final int MARGIN_WIDTH_EDEFAULT = 5;

	/**
	 * The cached value of the '{@link #getMarginWidth() <em>Margin Width</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMarginWidth()
	 * @generated
	 * @ordered
	 */
	protected int marginWidth = MARGIN_WIDTH_EDEFAULT;

	/**
	 * The default value of the '{@link #getMarginHeight() <em>Margin Height</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMarginHeight()
	 * @generated
	 * @ordered
	 */
	protected static final int MARGIN_HEIGHT_EDEFAULT = 5;

	/**
	 * The cached value of the '{@link #getMarginHeight() <em>Margin Height</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMarginHeight()
	 * @generated
	 * @ordered
	 */
	protected int marginHeight = MARGIN_HEIGHT_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MGridLayoutImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SwtmodelPackage.Literals.MGRID_LAYOUT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getNumColumns() {
		return numColumns;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumColumns(int newNumColumns) {
		int oldNumColumns = numColumns;
		numColumns = newNumColumns;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SwtmodelPackage.MGRID_LAYOUT__NUM_COLUMNS, oldNumColumns, numColumns));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isMakeColumnsEqualWidth() {
		return makeColumnsEqualWidth;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMakeColumnsEqualWidth(boolean newMakeColumnsEqualWidth) {
		boolean oldMakeColumnsEqualWidth = makeColumnsEqualWidth;
		makeColumnsEqualWidth = newMakeColumnsEqualWidth;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SwtmodelPackage.MGRID_LAYOUT__MAKE_COLUMNS_EQUAL_WIDTH, oldMakeColumnsEqualWidth, makeColumnsEqualWidth));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getMarginWidth() {
		return marginWidth;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMarginWidth(int newMarginWidth) {
		int oldMarginWidth = marginWidth;
		marginWidth = newMarginWidth;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SwtmodelPackage.MGRID_LAYOUT__MARGIN_WIDTH, oldMarginWidth, marginWidth));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getMarginHeight() {
		return marginHeight;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMarginHeight(int newMarginHeight) {
		int oldMarginHeight = marginHeight;
		marginHeight = newMarginHeight;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SwtmodelPackage.MGRID_LAYOUT__MARGIN_HEIGHT, oldMarginHeight, marginHeight));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SwtmodelPackage.MGRID_LAYOUT__NUM_COLUMNS:
				return new Integer(getNumColumns());
			case SwtmodelPackage.MGRID_LAYOUT__MAKE_COLUMNS_EQUAL_WIDTH:
				return isMakeColumnsEqualWidth() ? Boolean.TRUE : Boolean.FALSE;
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_WIDTH:
				return new Integer(getMarginWidth());
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_HEIGHT:
				return new Integer(getMarginHeight());
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SwtmodelPackage.MGRID_LAYOUT__NUM_COLUMNS:
				setNumColumns(((Integer)newValue).intValue());
				return;
			case SwtmodelPackage.MGRID_LAYOUT__MAKE_COLUMNS_EQUAL_WIDTH:
				setMakeColumnsEqualWidth(((Boolean)newValue).booleanValue());
				return;
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_WIDTH:
				setMarginWidth(((Integer)newValue).intValue());
				return;
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_HEIGHT:
				setMarginHeight(((Integer)newValue).intValue());
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SwtmodelPackage.MGRID_LAYOUT__NUM_COLUMNS:
				setNumColumns(NUM_COLUMNS_EDEFAULT);
				return;
			case SwtmodelPackage.MGRID_LAYOUT__MAKE_COLUMNS_EQUAL_WIDTH:
				setMakeColumnsEqualWidth(MAKE_COLUMNS_EQUAL_WIDTH_EDEFAULT);
				return;
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_WIDTH:
				setMarginWidth(MARGIN_WIDTH_EDEFAULT);
				return;
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_HEIGHT:
				setMarginHeight(MARGIN_HEIGHT_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SwtmodelPackage.MGRID_LAYOUT__NUM_COLUMNS:
				return numColumns != NUM_COLUMNS_EDEFAULT;
			case SwtmodelPackage.MGRID_LAYOUT__MAKE_COLUMNS_EQUAL_WIDTH:
				return makeColumnsEqualWidth != MAKE_COLUMNS_EQUAL_WIDTH_EDEFAULT;
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_WIDTH:
				return marginWidth != MARGIN_WIDTH_EDEFAULT;
			case SwtmodelPackage.MGRID_LAYOUT__MARGIN_HEIGHT:
				return marginHeight != MARGIN_HEIGHT_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (numColumns: ");
		result.append(numColumns);
		result.append(", makeColumnsEqualWidth: ");
		result.append(makeColumnsEqualWidth);
		result.append(", marginWidth: ");
		result.append(marginWidth);
		result.append(", marginHeight: ");
		result.append(marginHeight);
		result.append(')');
		return result.toString();
	}

} //MGridLayoutImpl
